/**
 * Created by wang on 2016-8-18.
 * 字典项
 */
define(['angular'], function (angular) {
    "use strict";

    var filter = function (DictionaryService) {
        /**
         * 原值 后缀 默认值
         */
        return function (text, key, def) {

            if(null == text || "undefined" == typeof(text) || "" == text){
                return "--";
            }else{
                if(angular.isDefined(key)) {
                    var values = DictionaryService.getByKey(key);
                    return values[text] ? values[text] : (def ? def : "--");
                }
                return  "--";
            }
        };
    };

    filter.$inject = ['DictionaryService'];
    return filter;
});